/**
 * Project Name:zbj-real-name-core-facade-impl
 * File Name:ToolsUtil.java
 * Package Name:com.zhubajie.real.name.core.util
 * Date:2016年8月11日下午1:34:07
 * Copyright (c) 2016, www.zbj.com All Rights Reserved.
 *
*/

package com.inoneone.youba.mcht.util;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.inoneone.youba.mcht.dto.req.BeginOrderReq;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * ClassName:日期工具类 <br/>
 * Function: TODO 描述功能. <br/>
 * Date: 2016年8月11日 下午1:34:07 <br/>
 * 
 * @author 姬远玄
 * @version
 * @since JDK 1.7
 * @see
 */
public class StringUtil {

	public static String getHiddenMoile(String mob) {
		if (CommonUtil.isNullOrEmpty(mob)) {
			return "";
		} else {
			return mob.replaceAll("\\d(?=\\d{4,7}$)", "*");
		}
	}

	/**
	 * Description: json解析</br>
	 * Date: 2017-07-05 14:30:02</br>
	 *
	 * @param
	 * @return
	 * @author 姬远玄
	 * @since JDK 1.7
	*/
	public static <T> T jsonParse(String jsonData, Class<T> valueType)
	{
		ObjectMapper mapper = new ObjectMapper();
		BeginOrderReq beginOrderReq;
		try {
			return  mapper.readValue(jsonData, valueType);
		} catch (Exception e) {
			throw new RuntimeException("json格式化异常", e);
		}
	}

	/**
	 * Description: json格式化</br>
	 * Date: 2017-07-05 14:29:54</br>
	 *
	 * @param
	 * @return
	 * @author 姬远玄
	 * @since JDK 1.7
	*/
	public static String jsonFormat(Object object)
	{
		ObjectMapper mapper = new ObjectMapper();
		try {
			return mapper.writeValueAsString(object);
		} catch (JsonProcessingException e) {
			throw new RuntimeException("json解析异常", e);
		}
	}
}
